package com.fengplus.demo.controller;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;

@RestController
@RequestMapping("/config")
@RefreshScope
public class ConfigController {

    @Value("${user.max}")
    private Integer userMax;

    @Value("${user.min}")
    private Integer userMin;

    @GetMapping("/user")
    public Map<String, Object> userConfig() {
        Map<String, Object> map = new HashMap<>();
        map.put("max", userMax);
        map.put("min", userMin);
        return map;
    }

}
